package blancosMikel.controller.servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import blancosMikel.controller.beans.catalogosBeans;
import blancosMikel.controller.beans.categoriasBeans;
import blancosMikel.controller.beans.informativaBeans;
import blancosMikel.controller.beans.marcaBeans;
import blancosMikel.controller.beans.productosBeans;
import blancosMikel.model.dao.categoriaDAO;
import blancosMikel.model.dao.informativaDAO;
import blancosMikel.model.dao.marcaDAO;
import blancosMikel.model.dao.productosDAO;

/**
 * Servlet implementation class productosSVR
 */
@WebServlet(description = "control de productos", urlPatterns = { "/productos" })
public class productosSVR extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public productosSVR() {
        super();
        System.out.println("SVR.Productos----------> Ejecutandose!");
    }

    /**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
		System.out.println("SVR.usuarios----------> doGet");
		response.sendRedirect("blancosMikel");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
		System.out.println("SVR.usuarios----------> doPost");
		String mapping = null;
		
		informativaBeans infoBean = new informativaBeans();
		productosBeans producto = new productosBeans();
		categoriasBeans categoria = new categoriasBeans();
		marcaBeans marca = new marcaBeans();
		catalogosBeans catalogo = new catalogosBeans();
		
		informativaDAO iDao = new informativaDAO();
		productosDAO pDao = new productosDAO();
		categoriaDAO cDao = new categoriaDAO();
		marcaDAO mDao = new marcaDAO();
		

		int dispatch = Integer.parseInt(request.getParameter("dispatch"));
		System.out.println("SVR.usuarios.doPost----------> Cargando el disparador");

		try {
			iDao.selectInfo(infoBean);
			switch (dispatch) {
			case 1: // Alta
				break;
			case 2: // Baja
				break;
			case 3: // Cambio
				break;	
			case 4: // Catalogo
				break;
			case 5: // Alta marcas
				break;
			case 6: // Baja marcas
				break;
			case 7: // Cambio marcas
				break;	
			case 8: // Catalogo marcas
				break;
			case 9: // Alta categorias
				break;
			case 10: // Baja categorias
				break;
			case 11: // Cambio categorias
				break;	
			case 12: // Catalogo categorias
				break;	
			}

		} catch (Exception error) {
			System.out.println("ChekSesion.doPost---->" + error.getMessage());
			request.setAttribute("infoBean", infoBean);
			request.setAttribute("mensaje", error.getMessage());
		} finally {
			request.getRequestDispatcher(mapping).forward(request, response);
		}
	}

}
